What is @babel/plugin-syntax-unicode-sets-regex?
The @babel/plugin-syntax-unicode-sets-regex package allows Babel to parse regular expressions that use the Unicode property escapes syntax within character classes. This is part of the ECMAScript 2021 specification. The plugin itself does not transform these regular expressions; it only enables Babel to understand them during the parsing phase, which is useful when working with next-generation JavaScript features.
What are @babel/plugin-syntax-unicode-sets-regex's main functionalities?
Parsing Unicode property escapes in regex
This feature allows Babel to parse regular expressions that include Unicode property escapes, such as matching characters of a specific script like Hiragana. The 'u' flag is necessary for these expressions.
/\p{Script=Hiragana}+/u
Other packages similar to @babel/plugin-syntax-unicode-sets-regex
@babel/plugin-transform-unicode-regex
This package transforms Unicode regular expressions into equivalent ES5 syntax. It complements @babel/plugin-syntax-unicode-sets-regex by not only allowing Babel to parse but also transform Unicode regexes, making it more suitable for projects targeting older environments.
regexpu-core
A library that transforms ES2015 Unicode regular expressions into ES5. It's similar to @babel/plugin-transform-unicode-regex but can be used outside of the Babel ecosystem. It provides a lower-level API for working directly with regular expressions.